home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
byt86oct.arc
/
ALLOC.ARC
/
ALLOC3.DEF
< prev
next >
Wrap
Text File
|
1985-07-12
|
2KB
|
44 lines
DEFINITION MODULE Alloc3;
(* A safe storage allocator using the first-fit method and handles.
Copyright 1986 by Jonathan Amsterdam. All Rights Reserved. *)
FROM SYSTEM IMPORT WORD;
EXPORT QUALIFIED handle, blockSize, getWord, setWord, allocate, free,
getFreeList, resize, writeMap;
TYPE handle; (* pointer to a pointer to a block*)
PROCEDURE blockSize(h:handle):CARDINAL;
(* Size of block *)
PROCEDURE getWord(h:handle; n:CARDINAL):WORD;
(* Returns n'th word of block. Block indexed from 0 to blockSize-1;
dies if n > blockSize-1. *)
PROCEDURE setWord(h:handle; n:CARDINAL; w:WORD);
(* sets n'th word of block to w; dies if n > blockSize-1. *)
PROCEDURE allocate(nWords:CARDINAL):handle;
(* allocates a block of nWords words (possibly slightly more, in some cases) *)
PROCEDURE free(VAR freeBlock:handle);
(* frees block pointed to by freeBlock if it points into the heap, and sets
freeBlock to NIL. *)
PROCEDURE resize(h:handle; nWords:CARDINAL);
(* attempts to change size of block referenced by h *)
PROCEDURE writeMap;
(* Writes, in order of address, the free and allocated blocks and their
sizes. For debugging only; should be removed in "production" versions
of the allocator. *)
PROCEDURE getFreeList():handle; (* really a blockPtr *)
(* Returns a pointer to the free list. For debugging only. This should
be removed in "production" versions of the allocator. *)
END Alloc3.
o the free list. For debugging only. This should
be removed in "